#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

const int N = 1e3+10;

bool cmp(string a, string b){
	string t1=a+b,t2=b+a;
	if(t1 < t2){
	cout<<t1<<endl;	
	return true;
	}
	else{
	cout<<t1<<endl;	 
	return false;
	}
	return true;
}

int main(){
	std::ios::sync_with_stdio(false);//第十个样例会卡输入，得关闭同步输入流
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		string ans, s[N];
		for(int i = 0; i < n; i++) cin >> s[i];
		sort(s,s+n,cmp);
		for(int i = 0; i < n; i++) ans += s[i];
		cout << ans << endl;
	}
	return 0;
}
